import { request } from "@/utils/service"
import type * as Canteen from "./types/canteen"

/** 分页查询食堂列表 */
export function getCanteenPageApi(params: Canteen.CanteenQueryParam) {
  return request<Canteen.CanteenListResponse>({
    url: "/canteen/page",
    method: "get",
    params
  })
}

/** 获取食堂列表 */
export function getCanteenListApi() {
  return request<Canteen.CanteenResponseData>({
    url: "/canteen/list",
    method: "get"
  })
}

/** 获取食堂详情 */
export function getCanteenDetailApi(canteenId: number) {
  return request<Canteen.CanteenDetailResponse>({
    url: `/canteen/detail/${canteenId}`,
    method: "get"
  })
}

/** 根据ID获取食堂信息 */
export function getCanteenByIdApi(id: number) {
  return request<Canteen.CanteenData>({
    url: `/canteen/${id}`,
    method: "get"
  })
}

/** 创建食堂 */
export function createCanteenApi(data: Canteen.CreateCanteenBean) {
  return request<Canteen.CreateCanteenResponse>({
    url: "/canteen/create",
    method: "post",
    data
  })
}

/** 更新食堂 */
export function updateCanteenApi(data: Canteen.UpdateCanteenBean) {
  return request<Canteen.UpdateCanteenResponse>({
    url: "/canteen/update",
    method: "post",
    data
  })
}

/** 删除食堂 */
export function deleteCanteenApi(canteenId: number) {
  return request<Canteen.DeleteCanteenResponse>({
    url: `/canteen/delete/${canteenId}`,
    method: "post"
  })
}

/** 批量删除食堂 */
export function batchDeleteCanteenApi(canteenIds: number[]) {
  return request<Canteen.BatchDeleteCanteenResponse>({
    url: "/canteen/batchDelete",
    method: "post",
    data: { ids: canteenIds }
  })
}

/** 更新食堂状态 */
export function updateCanteenStatusApi(canteenId: number, status: number) {
  return request<Canteen.UpdateCanteenStatusResponse>({
    url: "/canteen/updateStatus",
    method: "post",
    data: { id: canteenId, status }
  })
}